﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace SharingCenter.Web.Classes
{
    using System.Xml.XPath;
    public static class ModuleChanges
    {
        public static void ModuleChange(string modName)
        {
            string fileName = HttpContext.Current.Server.MapPath(WebConsts.APPDATA_DIR + "/ModuleChanges.xml");
            XDocument doc = XDocument.Load(fileName);
            XElement modEl = doc.XPathSelectElement("//module[@name='" + modName + "']");
            if (modEl != null)
            {
                modEl.Attribute("changelabel").Value = DateTime.Now.ToString();
            }
            else
            {
                modEl = new XElement("module",
                    new XAttribute("name", modName),
                    new XAttribute("changelabel", DateTime.Now.ToString()));
                doc.Root.Add(modEl);
            }

            doc.Save(fileName);
        }
    }
}